package com.android.tiango.baba.view;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager.LayoutParams;
import android.widget.ImageButton;
import android.widget.ImageView;

import com.android.scsd.tiango.R;

public class SharePopWindow extends Dialog implements android.view.View.OnClickListener {
	private ImageButton ibClose;
	public ImageView iv_sina;
	public ImageView iv_wxfriends;
	public ImageView iv_qq;
	public ImageView iv_tiangou;
	private ShareInterface share;

	// public static final int NEWS_INFO = 1;// 最新资讯分享
	// public static final int PANIC_BUYING = 2;// 零远抢购分享
	// public static final int SPECIALLY_ACTIVE = 3;// 专题活动分享

	public SharePopWindow(Context context) {
		super(context);
		initViews(context);
	}

	public void initViews(Context context) {
		int res = R.layout.layout_share_window;
		View view = LayoutInflater.from(context).inflate(res, null);
		ibClose = (ImageButton) view.findViewById(R.id.ib_close);
		iv_sina = (ImageView) view.findViewById(R.id.iv_sina);
		iv_wxfriends = (ImageView) view.findViewById(R.id.iv_wxfriends);
		iv_qq = (ImageView) view.findViewById(R.id.iv_qq);
		iv_tiangou = (ImageView) view.findViewById(R.id.iv_tiangou);

		ibClose.setOnClickListener(this);
		iv_sina.setOnClickListener(this);
		iv_wxfriends.setOnClickListener(this);
		iv_qq.setOnClickListener(this);
		iv_tiangou.setOnClickListener(this);

		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(view);
		Window window = getWindow();
		window.setGravity(Gravity.LEFT);
		// 设置SelectPicPopupWindow弹出窗体动画效果
		window.setWindowAnimations(R.style.PopupAnimation_SetTip);
		// 设置SelectPicPopupWindow弹出窗体的背景
		window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

		LayoutParams lp = window.getAttributes();
		// 设置SelectPicPopupWindow弹出窗体的宽
		lp.width = LayoutParams.MATCH_PARENT;
		// 设置SelectPicPopupWindow弹出窗体的高
		lp.height = LayoutParams.MATCH_PARENT;

	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.iv_sina:
			share.sinaShare();
			break;
		case R.id.iv_wxfriends:
			share.wxcircleShare();
			break;
		case R.id.iv_qq:
			share.tentShare();
			break;
		case R.id.iv_tiangou:
			share.wxcircleShare();
			break;
		default:
			break;
		}
		dismiss();
	}

	public interface ShareInterface {
		/**
		 * 新浪分享
		 */
		public void sinaShare();

		/**
		 * 腾讯分享
		 */
		public void tentShare();

		/**
		 *  微信朋友圈
		 */
		public void wxcircleShare();

		/**
		 * 分享到天购
		 */
		public void tiangouShare();
	}

	public void setShareInterface(ShareInterface share) {
		this.share = share;

	}
}
